local chengxiang = fk.CreateSkill {

  name = "joy__chengxiang",

  tags = { Skill.Compulsory, },

}



chengxiang:addEffect(fk.Damaged, {
  name = "joy__chengxiang",
  anim_type = "masochism",
  events = {fk.Damaged},
  frequency = Skill.Compulsory,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getNCards(4)
    room:moveCards({
      ids = cards,
      toArea = Card.Processing,
      moveReason = fk.ReasonPut,
    })
    local get = room:askForArrangeCards(player, chengxiang.name, {cards},
    "#chengxiang-choose", false, 0, {4, 4}, {0, 1}, ".", "chengxiang_count", {{}, {cards[1]}})[2]
    room:moveCardTo(get, Player.Hand, player, fk.ReasonJustMove, chengxiang.name, "", true, player.id)
    cards = table.filter(cards, function(id) return room:getCardArea(id) == Card.Processing end)
    if #cards > 0 then
      room:moveCards({
        ids = cards,
        toArea = Card.DiscardPile,
        moveReason = fk.ReasonPutIntoDiscardPile,
      })
    end
  end
})

return chengxiang